package cn.tedu.oa.schedule.service.impl;

import cn.tedu.oa.schedule.mapper.ScheduleMapper;
import cn.tedu.oa.schedule.pojo.dto.ScheduleQuerry;
import cn.tedu.oa.schedule.pojo.dto.ScheduleSaveParam;
import cn.tedu.oa.schedule.pojo.entity.Schedule;
import cn.tedu.oa.schedule.pojo.vo.ScheduleVO;
import cn.tedu.oa.schedule.service.ScheduleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
@Slf4j
public class ScheduleImpl  implements ScheduleService {
    @Autowired
    private ScheduleMapper scheduleMapper;
    @Override
    public List<ScheduleVO> select(ScheduleQuerry scheduleQuerry) {
        List<ScheduleVO> list = scheduleMapper.select(scheduleQuerry);
        return list;
    }

    @Override
    public void save(ScheduleSaveParam scheduleSaveParam) {
        Schedule schedule = new Schedule();
        BeanUtils.copyProperties(scheduleSaveParam,schedule);
        if (schedule.getId()==null){
            scheduleMapper.insert(schedule);
        }else{
            scheduleMapper.update(schedule);
        }


    }

    @Override
    public void delete(Integer id) {
        scheduleMapper.delete(id);
    }
}
